dist: trusty
sudo: required # workaround travis + kcov issue (https://github.com/travis-ci/travis-ci/issues/9061)
language: cpp

os:
  - linux

compiler:
  - gcc
  - clang

env:
  global:
    - PATH=${PATH}:${HOME}/kcov/bin
    - CODECOV_TOKEN="e8770d8b-fe55-45b0-bd30-4c73984ef099"
  matrix:
  - TARGET_CPU=amd64
  - TARGET_CPU=x86

addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - g++-5
      - clang
      # kcov
      - binutils-dev
      - libcurl4-openssl-dev
      - zlib1g-dev
      - libdw-dev
      - libiberty-dev

before_install:
  - wget -O kcov-master.tar.gz https://github.com/SimonKagstrom/kcov/archive/master.tar.gz

install:
  - uname -a
  - if [ "$CXX" = "g++" ]; then export CXX="/usr/bin/g++-5" CC="/usr/bin/gcc-5"; fi
  - $CC --version
  - $CXX --version
  # build & install kcov
  - tar xzf kcov-master.tar.gz
  - cd kcov-master
  - mkdir build
  - cd build
  - cmake -DCMAKE_INSTALL_PREFIX=${HOME}/kcov ..
  - make
  - make install
  - cd ../..
  - rm -rf kcov-master

script:
  - mkdir build
  - cd build
  - cmake .. -DTARGET_CPU=$TARGET_CPU -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID
  - cmake --build . -- -j2
  - ctest -V .

after_success:
  - $TRAVIS_BUILD_DIR/scripts/codecov.sh -s /tmp/kcov
